package com.atstudy.headline.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.Date;
import lombok.Data;

/**
 * 广告展示记录表
 * @TableName ad_impressions
 */
@TableName(value ="ad_impressions")
@Data
public class AdImpressions {
    /**
     * 展示记录ID
     */
    @TableId(type = IdType.AUTO)
    private Integer impressionId;

    /**
     * 广告创意ID
     */
    private Integer creativeId;

    /**
     * 用户ID
     */
    private Integer userId;

    /**
     * 展示位置内容ID
     */
    private Integer contentId;

    /**
     * 展示位置编码（1:文章页顶部，2:文章页底部，3:信息流）
     */
    private Integer positionCode;

    /**
     * 展示时间
     */
    private Date impressionTime;

    /**
     * IP地址
     */
    private String ipAddress;

    /**
     * 设备信息
     */
    private Object deviceInfo;

    /**
     * 地理位置
     */
    private Object location;

    // 关联字段
    //创意名称
    @TableField(exist = false)
    private String creativeTitle;

    // 用户名
    @TableField(exist = false)
    private String username;

    // 内容标题
    @TableField(exist = false)
    private String contentTitle;


    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        AdImpressions other = (AdImpressions) that;
        return (this.getImpressionId() == null ? other.getImpressionId() == null : this.getImpressionId().equals(other.getImpressionId()))
            && (this.getCreativeId() == null ? other.getCreativeId() == null : this.getCreativeId().equals(other.getCreativeId()))
            && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
            && (this.getContentId() == null ? other.getContentId() == null : this.getContentId().equals(other.getContentId()))
            && (this.getPositionCode() == null ? other.getPositionCode() == null : this.getPositionCode().equals(other.getPositionCode()))
            && (this.getImpressionTime() == null ? other.getImpressionTime() == null : this.getImpressionTime().equals(other.getImpressionTime()))
            && (this.getIpAddress() == null ? other.getIpAddress() == null : this.getIpAddress().equals(other.getIpAddress()))
            && (this.getDeviceInfo() == null ? other.getDeviceInfo() == null : this.getDeviceInfo().equals(other.getDeviceInfo()))
            && (this.getLocation() == null ? other.getLocation() == null : this.getLocation().equals(other.getLocation()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getImpressionId() == null) ? 0 : getImpressionId().hashCode());
        result = prime * result + ((getCreativeId() == null) ? 0 : getCreativeId().hashCode());
        result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
        result = prime * result + ((getContentId() == null) ? 0 : getContentId().hashCode());
        result = prime * result + ((getPositionCode() == null) ? 0 : getPositionCode().hashCode());
        result = prime * result + ((getImpressionTime() == null) ? 0 : getImpressionTime().hashCode());
        result = prime * result + ((getIpAddress() == null) ? 0 : getIpAddress().hashCode());
        result = prime * result + ((getDeviceInfo() == null) ? 0 : getDeviceInfo().hashCode());
        result = prime * result + ((getLocation() == null) ? 0 : getLocation().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", impressionId=").append(impressionId);
        sb.append(", creativeId=").append(creativeId);
        sb.append(", userId=").append(userId);
        sb.append(", contentId=").append(contentId);
        sb.append(", positionCode=").append(positionCode);
        sb.append(", impressionTime=").append(impressionTime);
        sb.append(", ipAddress=").append(ipAddress);
        sb.append(", deviceInfo=").append(deviceInfo);
        sb.append(", location=").append(location);
        sb.append("]");
        return sb.toString();
    }
}
